﻿#region

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using Microsoft.Practices.Composite.Presentation;
using Microsoft.Practices.Unity.Utility;

#endregion

namespace pushbomb.composite.core.DynamicObject
{
    [CollectionDataContract(IsReference = true)]
    public class DynamicProperyBag : ObservableCollection<Pair<string,object>> , IDictionary<String,object> {
      
        
        
        IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
        {
            return Items.Select(x => new KeyValuePair<string,object>(x.First, x.Second)).GetEnumerator();
        }

        public void Add(KeyValuePair<string, object> item)
        {
          
            Add(  Pair.Make(item.Key, item.Value));
        }

        public bool Contains(KeyValuePair<string, object> item)
        {
            return false;
        }

        public void CopyTo(KeyValuePair<string, object>[] array, int arrayIndex)
        {
        }

        public bool Remove(KeyValuePair<string, object> item)
        {
            return false;
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public bool ContainsKey(string key)
        {
            return false;
        }

        public void Add(string key, object value)
        {
            Add(new Pair<string, object>(key, value));
        }

        public bool Remove(string key)
        {
            return false;
        }

        public bool TryGetValue(string key, out object value)
        {
            value = null;
            return false;
        }

        public object this[string key]
        {
            get { return null; }
            set { }
        }

        public ICollection<string> Keys
        {
            get { return Items.Select(x => x.First).ToArray(); }
        }

        public ICollection<object> Values
        {
            get { return Items.Select(x => x.Second).ToArray(); }
        }
    }
}